Using Sub-Detail Bands
Introduction
Sub-detail bands increase the Band Editor’s functionality by allowing sub-reports that provide additional information for each record in the detail band. A sub-detail band prints one dataset while being linked to another dataset (called the master). As each record prints in the master dataset, Argos executes the dataset in the sub-detail band and prints the sub-detail band once for each row returned. Any number of sub-detail bands can be created, and they all follow the parent detail band.
In most cases, the master dataset is the main report query (ArgosData). The dataset displayed in a sub-detail band is a different dataset; in fact, it can be from a different database, as long as both datasets have a common field which can be used to link them.
Note: A sub-detail band always prints after the detail band and will loop through all records in its dataset before the master dataset increments to the next record. For this reason, this technique is less efficient than other methods such as including additional information in a group header or footer band, and should be used only when required.
You should use sub-detail bands when:
- You need to loop through two or more datasets for each row in the detail band. Other methods only allow one dataset to be associated with each detail band.
- You need to loop through one or more datasets for each row in the detail band, but the data comes from a different database.
The Report Contents
In this example, we use sub-detail bands to add additional information to an employee list. This information includes employee contact information such as phone number, email address, contact information, and dependent information. Each type of contact appears in its own sub-detail band, and each is associated with the detail band, which contains the employee name and ID number.
In this example, we will be using the Employee, Employee_Phone, Employee_Email, Employee_Emerg_Contact, and Employee_Dependents tables within the sample database. The master dataset (ArgosData) contains the Employee table, which is linked to the other tables through the emp_id column. The other four tables will be used in the queries for the datasets we will be creating later in this exercise.
Since four datasets are associated with and are printed immediately after the detail band, the use of sub-detail bands is required (other methods only allow one dataset to be linked to a detail band).
The figure below shows the relationships of the tables within the sample database that are used in this example.
Note that none of the tables are joined, since for this example these tables are considered separate datasets from the Main Report DataBlock. This also simulates the situation where the datasets exist in an entirely different database from the database used by the DataBlock.
A report is to be created such that for each employee within the Employees table, associated records within the other datasets will be printed. The emp_id is used as the field to link the datasets together. Each dataset will exist within its own sub-detail band. The report will appear as follows with each sub-detail band identified:
For each employee, the associated Telephone Number records, Email Address records, Emergency Contact records, and Dependent Information records are printed. If a particular dataset is empty it will not print (Employee 683 has no email or dependent information). Each employee record can have any number of telephone, email, emergency contact, and dependent records associated with it.